package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 会话事件处理状态枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum SessionEventHandlingStatus implements BaseEnum {
    /** 待处理 */
    PENDING("PENDING", "待处理"),
    /** 处理中 */
    IN_PROGRESS("IN_PROGRESS", "处理中"),
    /** 已处理 */
    HANDLED("HANDLED", "已处理"),
    /** 已忽略 */
    IGNORED("IGNORED", "已忽略"),
    /** 已取消 */
    CANCELLED("CANCELLED", "已取消"),
    /** 处理失败 */
    FAILED("FAILED", "处理失败"),
    /** 需要人工干预 */
    MANUAL_REQUIRED("MANUAL_REQUIRED", "需要人工干预");

    private final String code;
    private final String description;

    SessionEventHandlingStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static SessionEventHandlingStatus fromCode(String code) {
        for (SessionEventHandlingStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }

    public static SessionEventHandlingStatus fromDescription(String description) {
        for (SessionEventHandlingStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}